package org.xiaoyu.rpc.remoting.packet;

import lombok.*;
import org.xiaoyu.rpc.common.url.URL;
import org.xiaoyu.rpc.seralization.support.SerializerAlgorithm;

/**
 * Created By Have
 * 2021/7/5 13:56
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Invocation implements Packet {

    /**
     * 待调用接口名称
     */
    private String serviceName;
    /**
     * 待调用方法名称
     */
    private String methodName;
    /**
     * 调用方法的参数
     */
    private Object[] parameters;
    /**
     * 调用方法的参数类型
     */
    private Class<?>[] paramTypes;

    private String requestId;

    private Throwable e;

    URL url;

    @Override
    public int getType() {
        return PacketType.REQUEST_PACK;
    }

    public boolean hasException() {
        return e != null;
    }

    public String getHost() {
        return url.getHost();
    }

    public int getPort() {
        return url.getPort();
    }
}
